package nowercoder.basics.exce01;

public class SelectSort {
    public void selectSort(int[] arr){
        if (arr == null || arr.length < 2) return;
        for (int i = 0; i < arr.length - 1; i++) {
            int minValue = i;
            for (int j = i+1; j < arr.length ; j++) {
                minValue = arr[j] > arr[minValue]? minValue:j;
            }
            swap(arr,i,minValue);
        }
    }

    public void swap(int [] arr,int i,int j){
        arr[i] = arr [i] ^ arr[j];
        arr[j] = arr [i] ^ arr[j];
        arr[i] = arr [i] ^ arr[j];
    }
}
